@push('title')
    <title>政策列表</title>
@endpush
@push('style2')
    <style>


        .layui-table-cell{
            height: auto;
            overflow:visible;
            text-overflow:inherit;
            white-space:normal;
            word-break: break-all;
        }
    </style>
@endpush
@extends('layout.layer')
@section('content')
<form class="layui-form layui-form-pane1" action="" lay-filter="policy-upload-form" style="margin:10px;">

    <input type="hidden" name="_token" value="{{csrf_token()}}">
    <input type="hidden" name="path" value="" id="file-path">
    <div class="layui-input-inline">
        <label class="layui-form-label" style="width: 100px">是否保留原政策</label>
        <div class="layui-input-inline">
        </div>
    </div>
    <div class="layui-input-inline">
        <div class="layui-input-inline">
            <input type="radio" name="delPolicy" value="0" title="保留原政策" checked>
            <input type="radio" name="delPolicy" value="1" title="删除原政策" >
        </div>
    </div>

    <div class="layui-input-inline">
        <label class="layui-form-label"  style="width: 100px">请选择航程类型</label>
        <div class="layui-input-inline">
        </div>
    </div>
    <br>
    <div class="layui-input-inline">
        <div class="layui-input-inline">
            <input type="radio" name="policyType" value="ROUND" title="往返" checked>
        </div>
    </div>
    <br>
    &nbsp;
    <br>
    <div class="layui-form-item">
        <button type="button" class="layui-btn layui-btn-normal" id="policy-upload-file"><i class="layui-icon"></i>选择文件</button>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="*">确认上传</button>
        </div>
    </div>
</form>
@endsection
@push('script')
    <script>

        layui.use(['form','upload','layer'], function() {

            var $=layui.$,
                form = layui.form,
                upload = layui.upload,
                layer = layui.layer;

            upload.render({
                elem: '#policy-upload-file'
                ,url: '/api/file/upload' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){

                    if (res.errcode == 0) {

                        layer.msg('上传完成', {
                            offset: '15px'
                            ,icon: 1
                            ,time: 500
                        }, function(){});

                        $('#policy-upload-file').html(res.data.name);
                        $('#file-path').val(res.data.path);

                    } else {

                        layer.msg('上传失败', {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1500
                        }, function(){});
                    }
                }
            });

            //监听提交
            form.on('submit(*)', function (data) {

                // 监听提交按钮
                $.ajax({
                    url: '/qnpolicy/roundBatchUpload'
                    , method: 'post'
                    , data: data.field
                    , dataType: 'json'
                    , success: function (res) {

                        layer.msg(res.errmsg, {
                            offset: '15px'
                            , icon: res.errcode == 0 ? 1 : 15
                            , time: 2000
                        }, function () {

                        });

                    },
                });

                return false;
            });

        });
    </script>


@endpush